package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/product/baseTrademark")
public class BaseTrademarkController {

    @Autowired
    private BaseTrademarkService baseTrademarkService;

    @ApiOperation("分页列表")
    @GetMapping("{page}/{limit}")
    public Result index(@PathVariable("page") Long page, @PathVariable("limit") Long limit) {
        return Result.ok(baseTrademarkService.getPage(page, limit));
    }

    @ApiOperation("获取BaseTrademark")
    @GetMapping("get/{id}")
    public Result get(@PathVariable("id") Long id) {
        BaseTrademark byId = baseTrademarkService.getById(id);
        return Result.ok(byId);
    }


    @ApiOperation("新增BaseTrademark")
    @PostMapping("save")
    public Result save(@RequestBody BaseTrademark baseTrademark) {
        baseTrademarkService.save(baseTrademark);
        return Result.ok();
    }


    @ApiOperation("修改BaseTrademark")
    @PutMapping("update")
    public Result update(@RequestBody BaseTrademark baseTrademark) {
        baseTrademarkService.updateById(baseTrademark);
        return Result.ok();
    }

    @ApiOperation("删除BaseTrademark")
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable("id") Long id) {
        baseTrademarkService.removeById(id);
        return Result.ok();
    }





}
